sh = icon-theme-installer.sh
theme = hicolor
themedir = /usr/share/icons/$(theme)
all_icons = sandcat-16.png sandcat-22.png sandcat-24.png sandcat-32.png  sandcat-48.png sandcat-64.png sandcat-128.png
theme_icons = \
	apps,sandcat-16.png \
	apps,sandcat-22.png \
	apps,sandcat-24.png \
	apps,sandcat-32.png \
	apps,sandcat-48.png \
	apps,sandcat-128.png

all-local:
	@(for icon_desc in $(theme_icons); do \
		category=$$(echo $$icon_desc | cut -f1 -d,); \
		src_file="$(srcdir)/$$(echo $$icon_desc | cut -f2 -d,)"; \
		dest_file=$$(echo $$src_file | ${SED} 's,\-[0-9][0-9]*,,'); \
		size=$$(echo $$src_file | ${SED} 's,[^0-9],,g'); \
		dest_dir="./bin/share/$(PACKAGE)/icons/hicolor/$${size}x$${size}/$${category}"; \
		mkdir -p "$${dest_dir}" && cp -f "$${src_file}" "$${dest_dir}/$${dest_file}"; \
	done;) &>/dev/null || true

install_icon_exec = ./$(sh) \
	-t "$(theme)" \
	-s "$(srcdir)" \
	-d "x$(DESTDIR)" \
	-b "$(themedir)" \
	-m "$(mkinstalldirs)" \
	-x "$(INSTALL_DATA)"

install-data-local:
	@-$(install_icon_exec) -i $(theme_icons)

uninstall-hook: 
	@-$(install_icon_exec) -u $(theme_icons)
	
EXTRA_DIST = $(all_icons) $(sh)